package net.zjitc.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.*;
import java.io.IOException;
import java.io.PrintWriter;

/**
 * Created by Administrator on 2017/9/28.
 */
@WebServlet(name = "HttpServletIP",urlPatterns = "/ipServlet")
public class HttpServletIP extends javax.servlet.http.HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        /**
         * 1.先从请求中获得对方IP
         * 拿对方对IP和被禁用对比较，是否相同，如果相同：提示：禁用
         * 如果不同，提示：欢迎
         * */
        response.setContentType("text/html;charset=utf-8");
        PrintWriter out=response.getWriter();
        String ip=request.getRemoteAddr();
        if ("171.68.8.5".equals(ip)){
            out.write("支付宝到账*1000");
        }else{
            out.write("支付宝-10000");
        }
    }
}
